
package de.lusiardi.webdav;

import de.lusiardi.webdav.headers.ContentLengthHeader;
import de.lusiardi.webdav.headers.DepthHeader;
import de.lusiardi.webdav.headers.DestinationHeader;
import de.lusiardi.webdav.headers.OverwriteHeader;
import de.lusiardi.webdav.headers.TimeOutHeader;
import de.lusiardi.webdav.methods.COPY;
import de.lusiardi.webdav.methods.LOCK;
import de.lusiardi.webdav.methods.MKCOL;
import de.lusiardi.webdav.methods.MOVE;
import de.lusiardi.webdav.methods.PROPFIND;
import de.lusiardi.webdav.methods.PROPPATCH;
import de.lusiardi.webdav.methods.UNLOCK;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Providers;

public interface WebDavResource {
    @LOCK
    Response lock(
            @HeaderParam(TimeOutHeader.KEY) final String timeout,
            @HeaderParam(DepthHeader.KEY) final String depth,
            @Context final UriInfo uriInfo,
            final InputStream entityStream,
            @HeaderParam(ContentLengthHeader.KEY) final long contentLength,
            @Context final Providers providers,
            @Context final HttpHeaders httpHeaders)
            throws IOException;

    @UNLOCK
    Response unlock(
            @HeaderParam("Lock-Token") final String lockToken);

    @GET
    @Produces("application/octet-stream")
    Response get();
    
    @HEAD
    Response head();

    @PUT
    @Consumes("application/octet-stream")
    Response put(
            @Context final UriInfo uriInfo,
            final InputStream entityStream,
            @HeaderParam(ContentLengthHeader.KEY) final long contentLength)
            throws IOException, URISyntaxException;

    @MKCOL
    Response mkcol();

    @Produces("application/xml")
    @PROPFIND
    Response propfind(
            @Context final UriInfo uriInfo,
            @HeaderParam(DepthHeader.KEY) final String depth,
            final InputStream entityStream,
            @HeaderParam(ContentLengthHeader.KEY) final long contentLength,
            @Context final Providers providers,
            @Context final HttpHeaders httpHeaders)
            throws URISyntaxException, IOException;

    @PROPPATCH
    Response proppatch(
            @Context final UriInfo uriInfo,
            final InputStream entityStream,
            @HeaderParam(ContentLengthHeader.KEY) final long contentLength,
            @Context final Providers providers,
            @Context final HttpHeaders httpHeaders)
            throws URISyntaxException, IOException;

    @COPY
    Response copy(
            @Context final UriInfo uriInfo,
            @HeaderParam(DestinationHeader.KEY) final String destination,
            @HeaderParam(OverwriteHeader.KEY) final String overwrite)
            throws URISyntaxException;

    @MOVE
    Response move(
            @Context final UriInfo uriInfo,
            @HeaderParam(OverwriteHeader.KEY) final String overwriteStr,
            @HeaderParam(DestinationHeader.KEY) final String destination)
            throws URISyntaxException;

    @DELETE
    Response delete();

    @Path("{resource}")
    Object findResource(
            @PathParam("resource") final String res);

    @OPTIONS
    Response options();
}
